home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
msdos
/
presnttn
/
pic_tc
/
demopic.c
next >
Wrap
Text File
|
1990-05-26
|
6KB
|
158 lines
/*****************************************************************************
* *
* DEMOPIC.C .... A demonstration of the CSH PIC_TC functions *
* for use with Turbo C * *
* *
* NOTE: Use DEMOPIC.PRJ project make file and compile using *
* the small memory model. *
* *
* PIC is a trademark of LOTUS corporation *
* Turbo C is a trademark of BORLAND INTERNATIONAL *
* *
*****************************************************************************/
/*****************************************************************************
* STANDARD C LIBRARY HEADER FILES *
*****************************************************************************/
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*****************************************************************************
* CUSTOM PIC ROUTINE PROTOTYPES *
*****************************************************************************/
#include "pic_tc.h"
main(){
int i;
char buffer[10],text[20];
float tick=0.15;
/*display title*/
clrscr();
gotoxy(1,1);
printf("----------------------------------------------------------------------------\n");
printf("Turbo C PIC library demo program\n");
printf("Version 1.1 Spring 1990\n");
printf("(c) CSH Services, 1990\n");
printf("----------------------------------------------------------------------------\n\n");
/*display description of demo*/
printf("This program will create a file called 'TRY.PIC' on the same drive and\n");
printf("subdirectory from which the demo is run. This PIC file will demonstrate\n");
printf("all of the features of the library and can be viewed with such commercial\n");
printf("software as Lotus 123 etc. The PIC file created is approximately 25 kbytes\n");
printf("in length, so there must be at least this amount of free space on the\n");
printf("appropriate drive\n\n");
/*option to quit*/
printf("Press ESC to abort demo...any other key to create TRY.PIC\n\n");
if(getch()==27){
printf("Demo aborted...goodbye\n\n");
return(0);
}
/*initiation*/
if(pic_open("try.pic")!=0){
printf("ERROR in opening file\n");
printf("Demo aborted...goodbye\n\n");
return(0);
}
/*set defaults*/
printf("File opened OK\n");
pic_set_sp(100,200,2100,2200);
pic_set_scale(-10.0,10.0,-10.0,10.0);
pic_set_font(1);
printf("....scaling set..");
/*display title*/
pic_set_cs(1.5,1.5);
pic_pu_move_abs(0,9);
pic_draw_text("Demonstration of PIC routines",0,0);
pic_set_cs(1.0,1.0);
pic_pu_move_rel(0,-1);
pic_draw_text("...a test of relative move...",0,0);
printf("..title drawn....\n");
/*draw 8 blocks in different colours*/
pic_set_cs(0.32,0.32);
pic_set_linetype(0);
for(i=1;i<=8;i++){
pic_set_colour(i);
pic_draw_block(4.5,-5+i,5.5,-4+i);
pic_pu_move_abs(4.25,-4.5+i);
itoa(i,buffer,10);
pic_draw_text(buffer,0,0);
}
pic_set_cs(0.4,0.4);
pic_pu_move_abs(4.0,0);
pic_draw_text("colour codes",3,2);
printf("....solid blocks drawn..");
/*draw 5 rectangle in different line styles*/
pic_set_cs(0.5,0.5);
for(i=0;i<5;i++){
strcpy(text,"Line type #");
pic_set_linetype(i);
pic_draw_rectangle(-7.5+i,-7.5+i,7.5-i,7.5-i);
pic_pu_move_abs(0,-7.5+i);
itoa(i,buffer,10);
strcat(text,buffer);
pic_draw_text(text,0,4);
}
printf("..rectangles drawn....\n");
/*draw circles*/
for(i=0;i<5;i++){
pic_set_colour(i+1);
pic_draw_circle(-6.5+i,6.5-i,1+i);
}
pic_set_colour(1);
printf("....circles drawn..");
/*draw x-axis*/
pic_set_linetype(0);
pic_pu_move_abs(-10,-9);
for(i=-10;i<=10;i++){
pic_pd_move_abs((float) i,-9);
pic_pd_move_rel(0,-tick);
pic_pu_move_rel(0,tick);
}
printf("..x-axis drawn....\n");
/*label x-axis*/
pic_set_cs(0.4,0.4);
pic_set_colour(3);
for(i=-10;i<=10;i++){
pic_pu_move_abs((float) i,-9);
pic_pu_move_rel(0,-(2*tick));
itoa(i,buffer,10);
pic_draw_text(buffer,0,2);
}
pic_set_colour(2);
printf("....x-axis labelled..");
/*draw copywrite notice*/
pic_set_font(2);
pic_set_cs(0.9,1.5);
pic_pu_move_abs(7.7,-7.5);
pic_draw_text("(c) CSH Services, 1990",1,1);
printf("..copywrite drawn....\n");
/*finish routine*/
i=pic_close();
switch(i){
case 0: printf("File closed OK\n");break;
default:printf("ERROR in closing file\n");
}
printf("\npress any key...to return to DOS\n\n");
getch();
clrscr();
return(0);
}